/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lily
 * Date: 2024-09-18
 * Time: 21:42
 */
public class search_Insert {
    public int searchInsert(int[] nums, int target) {
        int left = 0, right = nums.length - 1;
        while (left < right) {
            int min = left + (right - left) / 2;
            if (nums[min] < target) {
                left = min + 1;
            } else {
                right = min;
            }
        }
        if (nums[left] < target) {
            return nums.length;
        }
        return left;
    }
}
